-- StoneStage
-- Created by huanghr Sep/30/2016
-- 石台

-- 初始化
function initStoneStage(self)
    local class = self.gridData.class;
    local buildingInfo = BuildingBonusM.queryBuildingView(class);

    if not buildingInfo then
        error("获取不到建筑查看配置，元素类型：" .. class);
        return;
    end

    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            -- 更新建筑访问
            self:updateBuildingVisit();

            -- 音效
            AudioM.playFx("ui_open1");

            -- 打开查看建筑
            self:openBuildingView(nil, nil, buildingInfo["dialog"]);
        end
    end

    -- 建筑图标
    local iconPath = getLevelItemIconPath(buildingInfo["icon"]);

    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);

    self.icon:setScale(0.75);

    self.item:addChild(self.icon);
    self.iconPath = iconPath;
end
